package uk.ac.bbk.dcs.pakdd2014;

import java.util.HashMap;

public class SalesDate {
	
	private int module;
	private int component;
	private HashMap<Date,Integer> sold;
	
	public SalesDate(int module, int component) {
		this.module = module;
		this.component = component;
		sold=new HashMap<Date,Integer>();
	}
	public int getModule() {
		return module;
	}
	public int getComponent() {
		return component;
	}
	public HashMap<Date, Integer> getSold() {
		return sold;
	}
	public void addSale(int year,int month,int quantity){
		Date date= new Date(year, month);
		if(sold.containsKey(date)){
			sold.put(date, sold.get(date)+quantity);
		} else sold.put(date, quantity);
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + component;
		result = prime * result + module;
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SalesDate other = (SalesDate) obj;
		if (component != other.component)
			return false;
		if (module != other.module)
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "SalesDate [module=" + module + ", component=" + component
				+ ", sold=" + sold + "]";
	}
	
	
}
